package com.premedsidekick;

import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;


public class MedAppN2KActivity extends ListActivity {
	String string;
	Context context;
	Resources resources;
	CharSequence sequence;
	String[] menu;
	TextView textview;
	Intent intent;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		context = this;
		resources = getResources();
        menu = resources.getStringArray(R.array.faq_menu);
       
		FAQBaseAdapter adapter = new FAQBaseAdapter();
		getListView().setDivider(null);
	    setListAdapter(adapter);
   }
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		//super.onListItemClick(l, v, position, id);
		/*
		Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.maindialog);
        dialog.setCancelable(true);
        dialog.setTitle("Myth vs Fact");
        context = getApplicationContext();
        TextView text = (TextView) dialog.findViewById(R.id.TextView01);
        */
		if (position == 0) {
			intent = new Intent(this, CommunityServiceFAQ.class);
		}	  
		else if (position == 1) {
			intent = new Intent(this, ResearchFAQ.class);
		}  
		else if (position == 2) {
			intent = new Intent(this, GradesFAQ.class);
		}
		else if (position == 3) {
			intent = new Intent(this, MajorFAQ.class);
		}
		else if (position == 4) {
			intent = new Intent(this, PersonalAttributesFAQ.class);
		}
		else if (position == 5) {
			intent = new Intent(this, TheApplicationProcessFAQ.class);
		}
		else if (position == 6) {
			intent = new Intent(this, LettersOfRecommendationFAQ.class);
		}
		else if (position == 7) {
			intent = new Intent(this, PersonalStatementFAQ.class);
		}
		else if (position == 8) {
			intent = new Intent(this, DiversityOfApplicantsFAQ.class);
		}
		else if (position == 9) {
			intent = new Intent(this, ExtracurricularActivitiesFAQ.class);
		}
		
		else if (position == 10) {
			intent = new Intent(this, ProfessionalismFAQ.class);
		}
		if (intent != null)
			startActivity(intent);
		/*
		sequence = Html.fromHtml(string);
		text.setText(sequence);
		/*
		//set up button
		Button button = (Button) dialog.findViewById(R.id.Button01);
		button.setOnClickListener(new OnClickListener() {
			  @Override
		      public void onClick(View v) {
			  finish();
		      }
		});
		*/
		//now that the dialog is set up, it's time to show it    
		//dialog.show();
	}
	public class FAQBaseAdapter extends BaseAdapter {
		LayoutInflater inflater = LayoutInflater.from(context);
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return menu.length;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				convertView = inflater.inflate(R.layout.listview_main, null);
				textview = (TextView)convertView.findViewById(R.id.listview_main);
				sequence = Html.fromHtml(menu[position]);
				textview.setText(sequence);
			}
			else {
				textview = (TextView)convertView.findViewById(R.id.listview_main);
				sequence = Html.fromHtml(menu[position]);
				textview.setText(sequence);
			}
			return convertView;
		}
		
	}

}